<template>
  <a-table
    ref="table"
    size="middle"
    bordered
    rowKey="id"
    :columns="columns"
    :dataSource="dataSource"
    :pagination="ipagination"
    :loading="loading"
    @change="handleTableChange"
    :customRow="customRow"
    class="antableClass"
  >
    <template v-slot:listName="text">
      <span v-html="text"></span>
    </template>
  </a-table>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
export default {
  props: {
    list: {
      type: String,
      default: ''
    },
    columns: {
      type: Array,
      default: []
    },
    param: {
      type: Object,
      default: () => ({
        orgId: '',
        proId: ''
      })
    },
    reload: {
      type: Boolean,
      default: false
    }
  },
  mixins: [JeecgListMixin],
  beforeMount() {
    this.url.list = this.list
    this.queryParam = Object.assign({}, this.param)
  },
  watch: {
    reload: {
      handler() {
        this.queryParam = Object.assign({}, this.param)
        if (this.queryParam.orgId != '') {
          this.url.list = this.list
          this.loadData(1)
        }
      },
      immediate: true
    }
  },
  data() {
    return {
      //   disableMixinCreated: true
      url: {
        list: ''
      }
    }
  },
  methods: {
    customRow(record) {
      return {
        on: {
          // 事件
          click: (event, a) => {
            this.handlerClickRow(record)
          }
        }
      }
    },
    handlerClickRow(recoed) {
      this.$emit('SelectRow', recoed)
    }
  }
}
</script>

<style lang="less" scoped>
@import '~@assets/less/tableTheme.less';
</style>
